package com.mangguo.tingjian;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.server.ConfigurableWebServerFactory;
import org.springframework.boot.web.server.ErrorPage;
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.http.HttpStatus;

@SpringBootApplication
public class MangguolistenApplication {

	public static void main(String[] args) {
		SpringApplication.run(MangguolistenApplication.class, args);
	}

	@Bean
	public WebServerFactoryCustomizer webServerFactoryCustomizer(){
		return (WebServerFactoryCustomizer<ConfigurableWebServerFactory>) factory -> {
			ErrorPage error404Page = new ErrorPage(HttpStatus.NOT_FOUND,"/index.html");
			ErrorPage error401Page = new ErrorPage(HttpStatus.UNAUTHORIZED,"/index.html");
			factory.addErrorPages(error404Page);
			factory.addErrorPages(error401Page);
		};
	}

}
